home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996…eptember: Technology Seed / Mac Tech Seed Sep '96 / Mac Tech Seed Sep '96.toast / mac / QuickDraw 3D 1.5d7 / Interfaces / QD3DRenderer.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-23  |  45.8 KB  |  1,433 lines  |  [TEXT/R*ch]

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        QD3DRenderer.h                                             **
  4.  **                                                                          **
  5.  **                                                                          **
  6.  **     Purpose:     Renderer types and routines                                   **
  7.  **                                                                          **
  8.  **                                                                          **
  9.  **                                                                          **
  10.  **     Copyright (C) 1992-1996 Apple Computer, Inc.  All rights reserved.     **
  11.  **                                                                          **
  12.  **                                                                          **
  13.  *****************************************************************************/
  14. #ifndef QD3DRenderer_h
  15. #define QD3DRenderer_h
  16.  
  17. #if defined(PRAGMA_ONCE) && PRAGMA_ONCE
  18.     #pragma once
  19. #endif  /*  PRAGMA_ONCE  */
  20.  
  21. #include "QD3DView.h"
  22. #include "QD3DSet.h"
  23. #if defined(WINDOW_SYSTEM_MACINTOSH) && WINDOW_SYSTEM_MACINTOSH  
  24. #include "Events.h"
  25. #endif /* WINDOW_SYSTEM_MACINTOSH */
  26. #if defined(WINDOW_SYSTEM_WIN32) && WINDOW_SYSTEM_WIN32  
  27. #include "windows.h"
  28. #endif /* WINDOW_SYSTEM_WIN32 */
  29.  
  30. #if defined(THINK_C) || defined(__SC__)
  31.     #pragma options(!pack_enums, !align_arrays)
  32.     #pragma SC options align=power
  33. #elif defined(__MWERKS__)
  34.     #pragma enumsalwaysint on
  35.     #pragma align_array_members off
  36.     #pragma options align=native
  37. #elif defined(__PPCC__)
  38.     #pragma options align=power
  39. #elif defined(__xlc) || defined(__xlC) || defined(__xlC__) || defined(__XLC121__)
  40.     #pragma options enum=int
  41. #endif
  42.  
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif    /* __cplusplus */
  46.  
  47. /******************************************************************************
  48.  **                                                                             **
  49.  **                            User Interface Things                             **
  50.  **                                                                             **
  51.  *****************************************************************************/
  52.  
  53. #if defined(WINDOW_SYSTEM_MACINTOSH) && WINDOW_SYSTEM_MACINTOSH  
  54. /*
  55.  *  A callback to an application's event handling code. This is needed to    
  56.  *  support movable modal dialogs. The dialog's event filter calls this      
  57.  *  callback with events it does not handle.                                 
  58.  *  If an application handles the event it should return kQ3True.            
  59.  *  If the application does not handle the event it must return kQ3False and 
  60.  *  the dialog's event filter will pass the event to the system unhandled.   
  61.  */
  62. typedef TQ3Boolean (*TQ3MacOSDialogEventHandler)( 
  63.     EventRecord     event);
  64.  
  65. typedef struct TQ3DialogAnchor {
  66.     TQ3MacOSDialogEventHandler clientEventHandler;
  67. } TQ3DialogAnchor;
  68.  
  69. #elif defined(WINDOW_SYSTEM_WIN32) && WINDOW_SYSTEM_WIN32  
  70.  
  71. typedef struct TQ3DialogAnchor {
  72.     HWND ownerWindow;    
  73. } TQ3DialogAnchor;
  74.  
  75. #else /* ! WINDOW_SYSTEM_MACINTOSH && ! WINDOW_SYSTEM_WIN32 */
  76.  
  77. typedef struct TQ3DialogAnchor {
  78.     char notUsed;  /* place holder */
  79. } TQ3DialogAnchor;
  80.  
  81. #endif /* ! WINDOW_SYSTEM_MACINTOSH && ! WINDOW_SYSTEM_WIN32 */
  82.  
  83. /******************************************************************************
  84.  **                                                                             **
  85.  **                                Renderer Functions                             **
  86.  **                                                                             **
  87.  *****************************************************************************/
  88.  
  89. QD3D_EXPORT TQ3RendererObject Q3Renderer_NewFromType(
  90.     TQ3ObjectType            rendererObjectType);
  91.  
  92. QD3D_EXPORT TQ3ObjectType Q3Renderer_GetType(
  93.     TQ3RendererObject        renderer);
  94.  
  95. /*
  96.  *    A bit set in this flag to indicates supported features
  97.  */
  98. #define kQ3RendererFeatureNone                            (0)            /* Implements nothing */
  99. #define kQ3RendererFeatureFlagHiddenSurfaceRemoval        (1U << 0)    /* Supports hidden surface removal */
  100. #define kQ3RendererFeatureFlagHiddenSurfaceRemovalDeep    (1U << 1)    /* >= 24 bit hidden surface removal precision */
  101. #define kQ3RendererFeatureFlagTexture                    (1U << 2)    /* Textures */
  102. #define kQ3RendererFeatureFlagTextureHighQuality        (1U << 3)    /* High-quality Textures (tri-linear or better) */
  103. #define kQ3RendererFeatureFlagTextureColor                (1U << 4)    /* Full color modulation and highlight of textures */
  104. #define kQ3RendererFeatureFlagTransparency                (1U << 5)    /* Transparency with RGB blending */
  105. #define kQ3RendererFeatureFlagTransparencyAlpha            (1U << 6)    /* Transparency with alpha blending */
  106. #define kQ3RendererFeatureFlagAntialiasing                (1U << 7)    /* AntiAliasing */
  107. #define kQ3RendererFeatureFlagShadows                    (1U << 8)    /* Shadows */
  108.  
  109. typedef unsigned long    TQ3RendererFeatureFlags;
  110.  
  111. /*
  112.  *    Q3Renderer_GetEditFeatures
  113.  *        Returns a mask of variable features in the renderer. A 1 bit does not 
  114.  *        indicate that this feature is currently "on", only that it is editable.
  115.  *        
  116.  *        You may "set" or "unset" these features using Q3Renderer_SetFeatures.
  117.  */
  118. QD3D_EXPORT TQ3Status Q3Renderer_GetEditFeatures(
  119.     TQ3RendererObject            renderer,
  120.     TQ3RendererFeatureFlags        *editableFlags);
  121.  
  122. /*
  123.  *    Q3Renderer_GetFeatures
  124.  *        Returns a mask of currently set features in the renderer. A 1 bit 
  125.  *        indicates that this feature is currently "on". Some features may be 
  126.  *        available but not turned on. Some features may be on (always), but 
  127.  *        not editable.
  128.  *
  129.  *    To get a complete mask of all available features, do:
  130.  *    
  131.  *        Q3Renderer_GetEditFeatures(renderer, &editable);
  132.  *        Q3Renderer_GetFeatures(renderer, &features);
  133.  *        totalFeatures = editable | features;
  134.  */
  135. QD3D_EXPORT TQ3Status Q3Renderer_GetFeatures(
  136.     TQ3RendererObject            renderer,
  137.     TQ3RendererFeatureFlags        *flags);
  138.  
  139. /*
  140.  *    Q3Renderer_SetFeatures
  141.  *        Turn on or off editable features in a renderer. 
  142.  *        Operation is:
  143.  *            newRendererFlags = 
  144.  *                (oldRendererFlags & ~editableFlags) |
  145.  *                (flags & editableFlags); 
  146.  */
  147. QD3D_EXPORT TQ3Status Q3Renderer_SetFeatures(
  148.     TQ3RendererObject            renderer,
  149.     TQ3RendererFeatureFlags        flags);
  150.  
  151.  
  152. #if defined(QD3D_OBSOLETE) && QD3D_OBSOLETE
  153.  
  154. /*
  155.  *    Non-blocking, flush all buffered graphics to rasterizer. May or
  156.  *    may not update the draw context.
  157.  *    
  158.  *    This function has been replaced by Q3View_Flush
  159.  */
  160. QD3D_EXPORT TQ3Status Q3Renderer_Flush(
  161.     TQ3RendererObject        renderer,
  162.     TQ3ViewObject            view);
  163.     
  164. /*
  165.  *    Blocking, flush all buffered graphics to rasterizer and update
  166.  *    draw context.
  167.  *    
  168.  *    This function has been replaced by Q3View_Sync
  169.  */
  170. QD3D_EXPORT TQ3Status Q3Renderer_Sync(
  171.     TQ3RendererObject        renderer,
  172.     TQ3ViewObject            view);
  173.     
  174. #endif  /*  QD3D_OBSOLETE  */
  175.  
  176. /*
  177.  *    Q3Renderer_HasModalConfigure
  178.  *        Determine if this renderer has a modal settings dialog.
  179.  *
  180.  *    Q3Renderer_ModalConfigure
  181.  *        Have the renderer pop up a modal dialog box to configure its settings.
  182.  *    dialogAnchor - is platform specific data passed by the client to support
  183.  *      movable modal dialogs. 
  184.  *    MacOS: this is a callback to the calling application's event handler.
  185.  *      The renderer calls this function with events not handled by the 
  186.  *      settings dialog. This is necessary in order to support movable modal 
  187.  *      dialogs. An application's event handler must return kQ3True if it 
  188.  *      handles the event passed to the callback or kQ3False if not. 
  189.  *      An application which doesn't want to support a movable modal configure
  190.  *      dialog should pass NULL for the clientEventHandler of TQ3DialogAnchor.
  191.  *    Win32: this is the HWND of the owning window (typically an application's
  192.  *      main window).
  193.  *  canceled - returns a boolean inditacating that the user canceled the 
  194.  *    dialog.
  195.  *      
  196.  */
  197. QD3D_EXPORT TQ3Boolean Q3Renderer_HasModalConfigure(
  198.     TQ3RendererObject        renderer);
  199.  
  200. QD3D_EXPORT TQ3Status Q3Renderer_ModalConfigure(
  201.     TQ3RendererObject        renderer, 
  202.     TQ3DialogAnchor         dialogAnchor, 
  203.     TQ3Boolean                *canceled);
  204.  
  205. /*
  206.  *    Q3Renderer_GetPrivateData
  207.  *        Allows an application to collect private renderer configuration data
  208.  *      which it will then save. For example in a preference file or in a 
  209.  *        style template. An application should tag this data with the 
  210.  *        Renderer's object  name.
  211.  *    
  212.  *        if dataBuffer is NULL actualDataSize returns the required size in 
  213.  *        bytes of a data buffer large enough to store private data. 
  214.  *
  215.  *      bufferSize in the actual size of the memory block pointed to by 
  216.  *        dataBuffer
  217.  *
  218.  *        actualDataSize - on return the actual number of bytes written to the 
  219.  *        buffer or if dataBuffer is NULL the required size of dataBuffer
  220.  * 
  221.  */
  222.  
  223. QD3D_EXPORT TQ3Status Q3Renderer_GetPrivateData(
  224.     TQ3RendererObject        renderer, 
  225.     unsigned char            *dataBuffer, 
  226.     unsigned long            bufferSize,
  227.     unsigned long            *actualDataSize);
  228.  
  229. QD3D_EXPORT TQ3Status Q3Renderer_SetPrivateData(
  230.     TQ3RendererObject        renderer, 
  231.     unsigned char            *dataBuffer, 
  232.     unsigned long            bufferSize);
  233.  
  234. /******************************************************************************
  235.  **                                                                             **
  236.  **                        Interactive Renderer Specific Functions                 **
  237.  **                                                                             **
  238.  *****************************************************************************/
  239.  
  240. /* 
  241.  *  CSG IDs attribute 
  242.  */
  243. #define kQ3AttributeTypeConstructiveSolidGeometryID \
  244.     Q3_OBJECT_TYPE('c','s','g','i')
  245.  
  246. #if defined(QD3D_OBSOLETE) && QD3D_OBSOLETE
  247. #define kQ3AttributeType_ConstructiveSolidGeometryID \
  248.     kQ3AttributeTypeConstructiveSolidGeometryID
  249. #endif  /*  QD3D_OBSOLETE  */
  250.  
  251. /* 
  252.  *  Object IDs, to be applied as attributes on geometries 
  253.  */
  254. #define kQ3SolidGeometryObjA    0
  255. #define kQ3SolidGeometryObjB    1
  256. #define kQ3SolidGeometryObjC    2
  257. #define kQ3SolidGeometryObjD    3
  258. #define kQ3SolidGeometryObjE    4
  259.  
  260. /* 
  261.  *  Possible CSG equations 
  262.  */
  263. typedef enum TQ3CSGEquation {
  264.     kQ3CSGEquationAandB            = (int)0x88888888,
  265.     kQ3CSGEquationAandnotB         = 0x22222222,
  266.     kQ3CSGEquationAanBonCad        = 0x2F222F22,
  267.     kQ3CSGEquationnotAandB        = 0x44444444,
  268.     kQ3CSGEquationnAaBorCanB    = 0x74747474
  269. } TQ3CSGEquation;
  270.  
  271. typedef enum TQ3HiddenSurfaceRemovalMode {
  272.     kQ3HiddenSurfaceRemovalMode_None,
  273.     kQ3HiddenSurfaceRemovalMode_Shallow,
  274.     kQ3HiddenSurfaceRemovalMode_Deep
  275. } TQ3HiddenSurfaceRemovalMode;
  276.  
  277. QD3D_EXPORT TQ3Status Q3InteractiveRenderer_SetCSGEquation(
  278.     TQ3RendererObject        renderer,
  279.     TQ3CSGEquation            equation);
  280.  
  281. QD3D_EXPORT TQ3Status Q3InteractiveRenderer_GetCSGEquation(
  282.     TQ3RendererObject        renderer,
  283.     TQ3CSGEquation            *equation);
  284.  
  285. QD3D_EXPORT TQ3Status Q3InteractiveRenderer_SetPreferences(
  286.     TQ3RendererObject        renderer,
  287.     long                    vendorID,
  288.     long                    engineID);
  289.  
  290. QD3D_EXPORT TQ3Status Q3InteractiveRenderer_GetPreferences(
  291.     TQ3RendererObject        renderer,
  292.     long                    *vendorID,
  293.     long                    *engineID);
  294.     
  295. QD3D_EXPORT TQ3Status Q3InteractiveRenderer_SetDoubleBufferBypass(
  296.     TQ3RendererObject        renderer,
  297.     TQ3Boolean                bypass);
  298.  
  299. QD3D_EXPORT TQ3Status Q3InteractiveRenderer_GetDoubleBufferBypass(
  300.     TQ3RendererObject        renderer,
  301.     TQ3Boolean                *bypass);
  302.  
  303. QD3D_EXPORT TQ3Status Q3InteractiveRenderer_SetHiddenSurfaceRemovalMode(
  304.     TQ3RendererObject            renderer,
  305.     TQ3HiddenSurfaceRemovalMode    hiddenSurfaceRemovalMode);
  306.  
  307. QD3D_EXPORT TQ3Status Q3InteractiveRenderer_GetHiddenSurfaceRemovalMode(
  308.     TQ3RendererObject            renderer,
  309.     TQ3HiddenSurfaceRemovalMode    *hiddenSurfaceRemovalMode);
  310.  
  311.  
  312. /******************************************************************************
  313.  **                                                                             **
  314.  **                            Plug-in Renderer API                             **
  315.  **                                                                             **
  316.  *****************************************************************************/
  317.  
  318. /*
  319.  *    These bits should be set in the flag to indicate class supported
  320. */
  321. #define kQ3XRendererClassSupportNone                (0)            /* nothing */
  322. #define kQ3XRendererClassSupportFlagDoubleBuffer    (1U << 0)    /* Handle Double buffering */
  323. #define kQ3XRendererClassSupportFlagClearBuffer        (1U << 1)    /* Handle DrawContext clearing */
  324.  
  325. typedef unsigned long TQ3XRendererClassSupportFlags;
  326.  
  327. /*
  328.  *    Registration
  329.  */
  330. QD3D_EXPORT TQ3XObjectClass Q3XRendererClass_Register(
  331.     TQ3ObjectType        objectType,
  332.     char                *rendererName,
  333.     TQ3XMetaHandler        metaHandler,
  334.     unsigned long        sizeofClassPrivate,
  335.     unsigned long        sizeofDataPrivate);
  336.  
  337.  
  338. /******************************************************************************
  339.  **                                                                             **
  340.  **                            Renderer View Tools                                 **
  341.  **                                                                             **
  342.  **                    You may only call these methods from a plug-in             **
  343.  **                                                                             **
  344.  *****************************************************************************/
  345.  
  346. /*
  347.  *    Call by a renderer to call the user "idle" method, with progress 
  348.  *    information.
  349.  *    
  350.  *    Pass in (view, 0, n) on first call
  351.  *    Pass in (view, 1..n-1, n) during rendering
  352.  *    Pass in (view, n, n) upon completion
  353.  *    
  354.  *    Note: The user must have supplied an idleProgress method with 
  355.  *    Q3XView_SetIdleProgressMethod. Otherwise, the generic idle method is
  356.  *    called with no progress data. e.g. the Q3View_SetIdleMethod method
  357.  *    is called instead. (current and final are ignored, essentially.)
  358.  *
  359.  *    Returns kQ3Failure if rendering is cancelled.
  360.  */
  361. QD3D_EXPORT TQ3Status Q3XView_IdleProgress(
  362.      TQ3ViewObject        view,
  363.      unsigned long        current,
  364.      unsigned long        completed);
  365.  
  366. /*
  367.  *    Called by an asynchronous renderer when it completes a frame.
  368.  */
  369. QD3D_EXPORT TQ3Status Q3XView_EndFrame(
  370.      TQ3ViewObject        view);
  371.  
  372. /******************************************************************************
  373.  **                                                                             **
  374.  **                            Renderer AttributeSet Tools                         **
  375.  **                                                                             **
  376.  **                    You may only call these methods from a plug-in             **
  377.  **                                                                             **
  378.  *****************************************************************************/
  379.  
  380. /*
  381.  *    Faster access to geometry attribute sets.
  382.  *    
  383.  *    Returns pointer to INTERNAL data structure for elements and attributes
  384.  *    in an attributeSet, or NULL if no attribute exists.
  385.  *    
  386.  *    For attributes of type kQ3AttributeType..., the internal data structure
  387.  *    is identical to the data structure used in Q3AttributeSet_Add.
  388.  */
  389. QD3D_EXPORT void *Q3XAttributeSet_GetPointer(
  390.      TQ3AttributeSet            attributeSet,
  391.      TQ3AttributeType        attributeType);
  392.      
  393. #define kQ3XAttributeMaskNone                        \
  394.     0L
  395.  
  396. #define kQ3XAttributeMaskSurfaceUV                    \
  397.     (1 << (kQ3AttributeTypeSurfaceUV - 1))
  398.  
  399. #define kQ3XAttributeMaskShadingUV                    \
  400.     (1 << (kQ3AttributeTypeShadingUV - 1))
  401.  
  402. #define kQ3XAttributeMaskNormal                        \
  403.     (1 << (kQ3AttributeTypeNormal - 1))
  404.  
  405. #define kQ3XAttributeMaskAmbientCoefficient            \
  406.     (1 << (kQ3AttributeTypeAmbientCoefficient - 1))
  407.  
  408. #define kQ3XAttributeMaskDiffuseColor                \
  409.     (1 << (kQ3AttributeTypeDiffuseColor - 1))
  410.  
  411. #define kQ3XAttributeMaskSpecularColor                \
  412.     (1 << (kQ3AttributeTypeSpecularColor - 1))
  413.  
  414. #define kQ3XAttributeMaskSpecularControl            \
  415.     (1 << (kQ3AttributeTypeSpecularControl - 1))
  416.  
  417. #define kQ3XAttributeMaskTransparencyColor            \
  418.     (1 << (kQ3AttributeTypeTransparencyColor - 1))
  419.  
  420. #define kQ3XAttributeMaskSurfaceTangent                \
  421.     (1 << (kQ3AttributeTypeSurfaceTangent - 1))
  422.  
  423. #define kQ3XAttributeMaskHighlightState                \
  424.     (1 << (kQ3AttributeTypeHighlightState - 1))
  425.  
  426. #define kQ3XAttributeMaskSurfaceShader                \
  427.     (1 << (kQ3AttributeTypeSurfaceShader - 1))
  428.  
  429. #define kQ3XAttributeMaskCustomAttribute            0x80
  430.  
  431. #define kQ3XAttributeMaskAll                        \
  432.     (                                                 \
  433.         kQ3XAttributeMaskSurfaceUV             |         \
  434.         kQ3XAttributeMaskShadingUV             |         \
  435.         kQ3XAttributeMaskNormal             |         \
  436.         kQ3XAttributeMaskAmbientCoefficient |         \
  437.         kQ3XAttributeMaskDiffuseColor         |         \
  438.         kQ3XAttributeMaskSpecularColor         |         \
  439.         kQ3XAttributeMaskSpecularControl     |         \
  440.         kQ3XAttributeMaskTransparencyColor     |         \
  441.         kQ3XAttributeMaskSurfaceTangent     |         \
  442.         kQ3XAttributeMaskHighlightState        |        \
  443.         kQ3XAttributeMaskSurfaceShader        |        \
  444.         kQ3XAttributeMaskCustomAttribute            \
  445.     )
  446.  
  447. #define kQ3XAttributeMaskInherited                    \
  448.     (                                                 \
  449.         kQ3XAttributeMaskSurfaceUV             |         \
  450.         kQ3XAttributeMaskShadingUV             |         \
  451.         kQ3XAttributeMaskNormal             |         \
  452.         kQ3XAttributeMaskAmbientCoefficient |        \
  453.         kQ3XAttributeMaskDiffuseColor         |         \
  454.         kQ3XAttributeMaskSpecularColor         |         \
  455.         kQ3XAttributeMaskSpecularControl     |         \
  456.         kQ3XAttributeMaskTransparencyColor     |         \
  457.         kQ3XAttributeMaskSurfaceTangent     |         \
  458.         kQ3XAttributeMaskHighlightState             \
  459.     )
  460.  
  461. #define kQ3XAttributeMaskInterpolated                \
  462.     (                                                 \
  463.         kQ3XAttributeMaskSurfaceUV             |         \
  464.         kQ3XAttributeMaskShadingUV             |         \
  465.         kQ3XAttributeMaskNormal             |         \
  466.         kQ3XAttributeMaskAmbientCoefficient |         \
  467.         kQ3XAttributeMaskDiffuseColor         |         \
  468.         kQ3XAttributeMaskSpecularColor         |         \
  469.         kQ3XAttributeMaskSpecularControl     |         \
  470.         kQ3XAttributeMaskTransparencyColor     |         \
  471.         kQ3XAttributeMaskSurfaceTangent     |         \
  472.     )
  473.  
  474. typedef unsigned long TQ3XAttributeMask;
  475.  
  476. QD3D_EXPORT TQ3XAttributeMask Q3XAttributeSet_GetMask(
  477.     TQ3AttributeSet            attributeSet);
  478.  
  479. /******************************************************************************
  480.  **                                                                             **
  481.  **                            Renderer Draw Context Tools                         **
  482.  **                                                                             **
  483.  *****************************************************************************/
  484.  
  485. typedef struct TQ3XDrawRegionPrivate    *TQ3XDrawRegion;
  486.  
  487. QD3D_EXPORT TQ3Status Q3XDrawContext_GetDrawRegion(
  488.     TQ3DrawContextObject    drawContext,
  489.     TQ3XDrawRegion            *drawRegion);
  490.  
  491. typedef enum TQ3XDrawContextValidationMasks {
  492.     kQ3XDrawContextValidationClearFlags            =    0x00000000L,
  493.  
  494.     kQ3XDrawContextValidationDoubleBuffer        =    1 << 0,
  495.     kQ3XDrawContextValidationShader                =    1 << 1,
  496.     kQ3XDrawContextValidationClearFunction        =    1 << 2,
  497.     kQ3XDrawContextValidationActiveBuffer        =    1 << 3,
  498.     kQ3XDrawContextValidationInternalOffScreen    =    1 << 4,
  499.     kQ3XDrawContextValidationPane                =    1 << 5,
  500.     kQ3XDrawContextValidationMask                =    1 << 6,
  501.     kQ3XDrawContextValidationDevice                =    1 << 7,
  502.     kQ3XDrawContextValidationWindow                =    1 << 8,
  503.     kQ3XDrawContextValidationWindowSize            =    1 << 9,
  504.     kQ3XDrawContextValidationWindowClip            =    1 << 10,
  505.     kQ3XDrawContextValidationWindowPosition        =    1 << 11,
  506.     kQ3XDrawContextValidationPlatformAttributes    =    1 << 12,
  507.     kQ3XDrawContextValidationForegroundShader    =    1 << 13,
  508.     kQ3XDrawContextValidationBackgroundShader    =    1 << 14,
  509.     kQ3XDrawContextValidationAll                =    ~0
  510. } TQ3XDrawContextValidationMasks;
  511.  
  512. typedef unsigned long TQ3XDrawContextValidation;
  513.  
  514. QD3D_EXPORT TQ3Status Q3XDrawContext_ClearValidationFlags(
  515.     TQ3DrawContextObject        drawContext);
  516.  
  517. QD3D_EXPORT TQ3Status Q3XDrawContext_GetValidationFlags(
  518.     TQ3DrawContextObject        drawContext,
  519.     TQ3XDrawContextValidation    *validationFlags);
  520.  
  521.  
  522. /******************************************************************************
  523.  **                                                                             **
  524.  **                            Renderer Draw Region Tools                         **
  525.  **                                                                             **
  526.  *****************************************************************************/
  527.  
  528. typedef enum TQ3XClipMaskState {
  529.     kQ3XClipMaskFullyExposed,
  530.     kQ3XClipMaskPartiallyExposed,
  531.     kQ3XClipMaskNotExposed
  532. } TQ3XClipMaskState;
  533.  
  534. typedef struct TQ3XDrawRegionClipMask {
  535.     unsigned char        *image;
  536.     unsigned long        width;
  537.     unsigned long        height;
  538.     unsigned long        rowBytes;
  539.     TQ3Endian            bitOrder;
  540. } TQ3XDrawRegionClipMask;
  541.  
  542.  
  543. typedef struct TQ3XDrawRegionDescriptor {
  544.     unsigned long        width;
  545.     unsigned long        height;
  546.     unsigned long        rowBytes;
  547.     unsigned long        pixelSize;
  548.     TQ3PixelType        pixelType;
  549.     TQ3Endian            bitOrder;
  550.     TQ3Endian            byteOrder;
  551. } TQ3XDrawRegionDescriptor;
  552.  
  553.  
  554. typedef void (*TQ3XDrawRegionRendererPrivateDeleteMethod)(
  555.     void    *rendererPrivate);
  556.  
  557. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetDeviceScaleX( 
  558.     TQ3XDrawRegion     drawRegion,
  559.     float            *deviceScaleX);
  560.  
  561. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetDeviceScaleY( 
  562.     TQ3XDrawRegion     drawRegion,
  563.     float            *deviceScaleY);
  564.  
  565.  
  566. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetDeviceOffsetX( 
  567.     TQ3XDrawRegion     drawRegion,
  568.     float            *deviceOffsetX);
  569.  
  570. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetDeviceOffsetY( 
  571.     TQ3XDrawRegion     drawRegion,
  572.     float            *deviceOffsetX);
  573.  
  574.  
  575. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetWindowScaleX( 
  576.     TQ3XDrawRegion     drawRegion,
  577.     float            *windowScaleX);
  578.  
  579. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetWindowScaleY( 
  580.     TQ3XDrawRegion     drawRegion,
  581.     float            *windowScaleY);
  582.  
  583.  
  584. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetWindowOffsetX( 
  585.     TQ3XDrawRegion     drawRegion,
  586.     float            *windowOffsetX);
  587.  
  588. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetWindowOffsetY( 
  589.     TQ3XDrawRegion     drawRegion,
  590.     float            *windowOffsetY);
  591.  
  592. QD3D_EXPORT TQ3Status Q3XDrawRegion_IsActive( 
  593.     TQ3XDrawRegion     drawRegion,
  594.     TQ3Boolean        *isActive);
  595.  
  596.  
  597. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetNextRegion( 
  598.     TQ3XDrawRegion     drawRegion,
  599.     TQ3XDrawRegion    *nextDrawRegion);
  600.  
  601.  
  602. QD3D_EXPORT TQ3Status Q3XDrawRegion_Start( 
  603.     TQ3XDrawRegion    drawRegion, 
  604.     TQ3Boolean        clear);
  605.  
  606. QD3D_EXPORT TQ3Status Q3XDrawRegion_End( 
  607.     TQ3XDrawRegion     drawRegion);
  608.  
  609. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetDeviceTransform( 
  610.     TQ3XDrawRegion     drawRegion,
  611.     TQ3Matrix4x4    **deviceTransform);
  612.  
  613. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetClipFlags( 
  614.     TQ3XDrawRegion         drawRegion,
  615.     TQ3XClipMaskState    *clipMaskState);
  616.     
  617. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetClipMask( 
  618.     TQ3XDrawRegion             drawRegion,
  619.     TQ3XDrawRegionClipMask    **clipMask);
  620.     
  621. #if defined(WINDOW_SYSTEM_MACINTOSH) && WINDOW_SYSTEM_MACINTOSH
  622.  
  623. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetClipRegion(
  624.     TQ3XDrawRegion    drawRegion,
  625.     RgnHandle        *rgnHandle);
  626.     
  627. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetGDHandle(
  628.     TQ3XDrawRegion    drawRegion,
  629.     GDHandle        *gdHandle);
  630.     
  631. #endif  /* WINDOW_SYSTEM_MACINTOSH  */     
  632.  
  633. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetRendererPrivate( 
  634.     TQ3XDrawRegion     drawRegion,
  635.     void            **rendererPrivate);
  636.  
  637. QD3D_EXPORT TQ3Status Q3XDrawRegion_SetRendererPrivate( 
  638.     TQ3XDrawRegion                                 drawRegion, 
  639.     const void                                     *rendererPrivate,
  640.     TQ3XDrawRegionRendererPrivateDeleteMethod    deleteMethod);
  641.  
  642. QD3D_EXPORT TQ3Status Q3XDrawRegion_SetUseDefaultRendererFlag( 
  643.     TQ3XDrawRegion    drawRegion, 
  644.     TQ3Boolean         flag);
  645.  
  646. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetUseDefaultRendererFlag( 
  647.     TQ3XDrawRegion    drawRegion,
  648.     TQ3Boolean        *useDefaultRenderingFlag);
  649.  
  650. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetNativeDescriptor(
  651.     TQ3XDrawRegion                    drawRegion,
  652.     const TQ3XDrawRegionDescriptor    **descriptor);
  653.     
  654. QD3D_EXPORT TQ3Status Q3XDrawRegion_UseDescriptor(
  655.     TQ3XDrawRegion                    drawRegion,
  656.     const TQ3XDrawRegionDescriptor    *descriptor);
  657.  
  658. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetImage(
  659.     TQ3XDrawRegion            drawRegion,
  660.     void                    **image);
  661.     
  662. QD3D_EXPORT TQ3Status Q3XDrawRegion_LookupColor(
  663.     TQ3XDrawRegion    drawRegion,
  664.     float            red,
  665.     float            green,
  666.     float            blue,
  667.     float            alpha,
  668.     unsigned long    *pixelValue);
  669.  
  670. QD3D_EXPORT TQ3Status Q3XDrawRegion_PutPixel(
  671.     TQ3XDrawRegion    drawRegion,
  672.     unsigned long    x,
  673.     unsigned long    y,
  674.     float            red,
  675.     float            green,
  676.     float            blue,
  677.     float            alpha);
  678.     
  679. QD3D_EXPORT TQ3Status Q3XDrawRegion_PutRaster(
  680.     TQ3XDrawRegion        drawRegion,
  681.     unsigned long        x,
  682.     unsigned long        y,
  683.     unsigned long        width,
  684.     unsigned long        height,
  685.     const TQ3ColorARGB    *raster);
  686.  
  687. /******************************************************************************
  688.  **                                                                             **
  689.  **                            Renderer Class Methods                             **
  690.  **                                                                             **
  691.  *****************************************************************************/
  692. /*
  693.  *    Methods from Object
  694.  *        kQ3XMethodTypeObjectClassRegister
  695.  *        kQ3XMethodTypeObjectClassUnregister
  696.  *        kQ3XMethodTypeObjectNew
  697.  *        kQ3XMethodTypeObjectDelete
  698.  *        kQ3XMethodTypeObjectRead
  699.  *        kQ3XMethodTypeObjectTraverse
  700.  *        kQ3XMethodTypeObjectWrite
  701.  *        
  702.  *    Methods from Shared
  703.  *        kQ3MethodTypeSharedEdited
  704.  *
  705.  *    Renderer Methods
  706.  *    
  707.  *    The renderer methods should be implemented according to the type
  708.  *    of renderer being written.
  709.  *
  710.  *    For the purposes of documentation, there are two basic types of
  711.  *    renderers: 
  712.  *
  713.  *        Interactive
  714.  *            Interactive Renderer
  715.  *            WireFrame Renderer
  716.  *        
  717.  *        Deferred
  718.  *            a ray-tracer
  719.  *            painter's algorithm renderer (cached in a BSP triangle tree)
  720.  *            an artistic renderer (simulates a pencil drawing, etc.)
  721.  *
  722.  *    The main difference is how each renderer handles incoming state and 
  723.  *    geometry.
  724.  *
  725.  *    An interactive renderer immediately transforms, culls, and shades
  726.  *    incoming geometry and performs rasterization. For example, in a 
  727.  *    single-buffered WireFrame renderer, you will see a new triangle
  728.  *    immediately after Q3Triangle_Draw (if it's visible, of course).
  729.  *
  730.  *    A deferred renderer caches the view state and each geometry, 
  731.  *    converting into any internal queue of drawing commands. Rasterization
  732.  *    is not actually performed until all data has been submitted.
  733.  *    
  734.  *    For example, a ray-tracer may not rasterize anything until the
  735.  *    end of the rendering loop, or until an EndFrame call is made.
  736.  */
  737.  
  738. /******************************************************************************
  739.  **                                                                             **
  740.  **                            Renderer Support Flags                             **
  741.  **                                                                             **
  742.  *****************************************************************************/
  743. /*
  744.  *    kQ3XMethodTypeRendererClassSupportFlag
  745.  *    TQ3XRendererClassSupportFlagMethod
  746.  *    
  747.  *    Return the TQ3XRendererClassSupportFlags for your renderer class. 
  748.  *
  749.  *    kQ3XRendererClassSupportFlagDoubleBuffer    
  750.  *        - the drawContext will not allocate or manage a back image buffer
  751.  *        - you must update the front buffer
  752.  *    kQ3XRendererClassSupportFlagClearBuffer
  753.  *        - the drawContext will not be cleared before startFrame
  754.  *        - you must clear the image buffer with the desired drawcontext
  755.  *            method.
  756.  *
  757.  *    If no method is supplied, the default is 0L.
  758.  *    
  759.  *    OPTIONAL
  760.  */
  761. #define kQ3XMethodTypeRendererClassSupportFlag \
  762.     Q3_METHOD_TYPE('r','d','s','f')
  763. typedef TQ3XRendererClassSupportFlags TQ3XRendererClassSupportFlagMethod;
  764.  
  765. /*
  766.  *    kQ3XMethodTypeRendererGetEditFeatures
  767.  *    TQ3XRendererGetEditFeaturesMethod
  768.  *    
  769.  *    Return the TQ3RendererFeatureFlags of the editable features of your 
  770.  *    renderer. 
  771.  *
  772.  *    If no method is supplied, or the kQ3MethodTypeRendererSetFeatures is
  773.  *    NULL, the default editableFlags is kQ3RendererFeatureNone.
  774.  *    
  775.  *    OPTIONAL
  776.  */
  777. #define kQ3XMethodTypeRendererGetEditFeatures \
  778.     Q3_METHOD_TYPE('r','d','f','e')
  779. typedef TQ3Status (*TQ3XRendererGetEditFeaturesMethod)(
  780.     TQ3RendererObject            renderer,
  781.     void                        *rendererPrivate,
  782.     TQ3RendererFeatureFlags        *editableFlags);
  783.  
  784. /*
  785.  *    kQ3MethodTypeRendererGetFeatures
  786.  *    TQ3XRendererGetFeaturesMethod
  787.  *    
  788.  *    Return the TQ3XRendererFeatureFlags of the current features set in
  789.  *    your renderer. 
  790.  *
  791.  *    If no method is supplied, the default flags is kQ3RendererFeatureNone.
  792.  *    
  793.  *    OPTIONAL
  794.  */
  795. #define kQ3XMethodTypeRendererGetFeatures \
  796.     Q3_METHOD_TYPE('r','d','f','g')
  797. typedef TQ3Status (*TQ3XRendererGetFeaturesMethod)(
  798.     TQ3RendererObject            renderer,
  799.     void                        *rendererPrivate,
  800.     TQ3RendererFeatureFlags        *flags);
  801.  
  802. /*
  803.  *    kQ3XMethodTypeRendererSetFeatures
  804.  *    TQ3XRendererSetFeaturesMethod
  805.  *    
  806.  *    Set the TQ3RendererFeatureFlags in the current features set of
  807.  *    your renderer. 
  808.  *
  809.  *    Operation is:
  810.  *        newRendererFlags = 
  811.  *            (oldRendererFlags & ~editableFlags) |
  812.  *            (flags & editableFlags); 
  813.  *
  814.  *    If no method is supplied, the Q3Renderer_GetEditFeatures always returns
  815.  *    kQ3RendererFeatureNone.
  816.  *    
  817.  *    OPTIONAL
  818.  */
  819. #define kQ3XMethodTypeRendererSetFeatures \
  820.     Q3_METHOD_TYPE('r','d','f','s')
  821. typedef TQ3Status (*TQ3XRendererSetFeaturesMethod)(
  822.     TQ3RendererObject            renderer,
  823.     void                        *rendererPrivate,
  824.     TQ3RendererFeatureFlags        flags);
  825.     
  826. /******************************************************************************
  827.  **                                                                             **
  828.  **                        Renderer User Interface Methods                         **
  829.  **                                                                             **
  830.  *****************************************************************************/
  831.  
  832. /*
  833.  *    TQ3XRendererModalConfigureMethod
  834.  *    
  835.  *    This method should pop up a modal dialog to edit the renderer settings 
  836.  *    found in the renderer private. 
  837.  *    
  838.  *    dialogAnchor - is platform specific data passed by the client to support
  839.  *      movable modal dialogs. 
  840.  *    MacOS: this is a callback to the calling application's event handler.
  841.  *      The renderer calls this function with events not handled by the 
  842.  *      settings dialog. This is necessary in order to support movable modal 
  843.  *      dialogs. An application's event handler must return kQ3True if it 
  844.  *      handles the event passed to the callback or kQ3False if not. 
  845.  *      An application which doesn't want to support a movable modal configure
  846.  *      dialog should pass NULL for the clientEventHandler of TQ3DialogAnchor.
  847.  *      A renderer should implement a non-movable style dialog in that case.
  848.  *    Win32: this is the HWND of the owning window (typically an application's
  849.  *      main window).  (Win32 application modal dialogs are always movable.)
  850.  *  canceled - returns a boolean inditacating that the user canceled the 
  851.  *    dialog.
  852.  *    
  853.  *    OPTIONAL
  854.  */
  855. #define kQ3XMethodTypeRendererModalConfigure \
  856.     Q3_METHOD_TYPE('r','d','m','c')    
  857. typedef TQ3Status (*TQ3XRendererModalConfigureMethod)(
  858.     TQ3RendererObject            renderer,
  859.     TQ3DialogAnchor             dialogAnchor, 
  860.     TQ3Boolean                    *canceled,    
  861.     void                        *rendererPrivate);
  862.  
  863. /*
  864.  *    TQ3XRendererGetPrivateDataMethod
  865.  *    
  866.  *        Allows an application to collect private configuration data from the
  867.  *      renderer
  868.  *      which it will then save. For example in a preference file or in a 
  869.  *        style template. An application should tag this data with the 
  870.  *        Renderer's object name.
  871.  *    
  872.  *        if dataBuffer is NULL actualDataSize returns the required size in 
  873.  *        bytes of a data bufferlarge enough to store private data. 
  874.  *
  875.  *      bufferSize in the actual size of the memory block pointed to by 
  876.  *        dataBuffer
  877.  *
  878.  *        actualDataSize - on return the actual number of bytes written to the
  879.  *        buffer or if dataBuffer is NULL the required size of dataBuffer
  880.  *
  881.  *    OPTIONAL
  882.  */
  883. #define kQ3XMethodTypeRendererGetPrivateData \
  884.     Q3_METHOD_TYPE('r','d','g','p')    
  885. typedef TQ3Status (*TQ3XRendererGetPrivateDataMethod)(
  886.     TQ3RendererObject            renderer, 
  887.     unsigned char                *dataBuffer, 
  888.     unsigned long                bufferSize,
  889.     unsigned long                *actualDataSize,    
  890.     void                        *rendererPrivate);
  891.  
  892. /*
  893.  *    TQ3XRendererSetPrivateDataMethod
  894.  *    
  895.  *        Allows an application to pass private configuration data which has previously
  896.  *      been obtained from a renderer via Q3Renderer_GetPrivateData. For example in a 
  897.  *      preference file or in a style
  898.  *      template. An application should tag this data with the Renderer's object
  899.  *      name.
  900.  *    
  901.  *        if dataBuffer is NULL returns the required size in bytes of a data buffer
  902.  *        large enough to store private data. 
  903.  *
  904.  *      bufferSize in the actual size of the memory block pointed to by dataBuffer
  905.  *
  906.  *      if dataBuffer is not NULL the return value is the actual number of bytes
  907.  *      written to the dataBuffer.
  908.  *
  909.  *    OPTIONAL
  910.  */
  911. #define kQ3XMethodTypeRendererSetPrivateData \
  912.     Q3_METHOD_TYPE('r','d','s','p')    
  913. typedef TQ3Status (*TQ3XRendererSetPrivateDataMethod)(
  914.     TQ3RendererObject            renderer, 
  915.     unsigned char                *dataBuffer, 
  916.     unsigned long                bufferSize,    
  917.     void                        *rendererPrivate);
  918.  
  919. /******************************************************************************
  920.  **                                                                             **
  921.  **                        Renderer Drawing State Methods                         **
  922.  **                                                                             **
  923.  *****************************************************************************/
  924. /*
  925.  *    TQ3RendererStartFrame
  926.  *    
  927.  *    The StartFrame method is called first at Q3View_StartRendering
  928.  *    and should:
  929.  *        - initialize any renderer state to defaults
  930.  *        - extract any and all useful data from the drawContext
  931.  *
  932.  *    If your renderer passed in kQ3RendererFlagClearBuffer at 
  933.  *    registration, then it should also:
  934.  *        - clear the drawContext 
  935.  *    
  936.  *        When clearing, your renderer may opt to:
  937.  *        - NOT clear anything (if you touch every pixel, for example)
  938.  *        - to clear with your own routine, or
  939.  *        - to use the draw context default clear method by calling 
  940.  *        Q3DrawContext_Clear. Q3DrawContext_Clear takes advantage of
  941.  *        any available hardware in the system for clearing.
  942.  *    
  943.  *    This call also signals the start of all default submit commands from
  944.  *    the view. The renderer will receive updates for the default view
  945.  *    state via its Update methods before StartPass is called.
  946.  *    
  947.  *    REQUIRED
  948.  */
  949. #define kQ3XMethodTypeRendererStartFrame    \
  950.     Q3_METHOD_TYPE('r','d','c','l')
  951. typedef TQ3Status (*TQ3XRendererStartFrameMethod)(
  952.     TQ3ViewObject            view,
  953.     void                    *rendererPrivate,
  954.     TQ3DrawContextObject    drawContext);
  955.     
  956. /*
  957.  *    kQ3XMethodTypeRendererStartPass
  958.  *    TQ3XRendererStartPassMethod
  959.  *    
  960.  *    The StartPass method is called during Q3View_StartRendering but after
  961.  *    the StartFrame command. It should:
  962.  *        - collect camera and light information
  963.  *    
  964.  *    If your renderer supports deferred camera transformation, camera is the
  965.  *    main camera which will be submitted in the hierarchy somewhere. It
  966.  *    is never NULL.
  967.  *
  968.  *    If your renderer does not support deferred camera transformation, camera
  969.  *    is the transformed camera.
  970.  *
  971.  *    If your renderer supports deferred light transformation, lights will be
  972.  *    NULL, and will be submitted to your light draw methods instead.
  973.  *
  974.  *    This call signals the end of the default update state, and the start of submit
  975.  *    commands from the user to the view.
  976.  *
  977.  *    REQUIRED
  978.  */
  979. #define kQ3XMethodTypeRendererStartPass \
  980.     Q3_METHOD_TYPE('r','d','s','t')
  981. typedef TQ3Status (*TQ3XRendererStartPassMethod)(
  982.     TQ3ViewObject            view,
  983.     void                    *rendererPrivate,
  984.     TQ3CameraObject            camera,
  985.     TQ3GroupObject            lightGroup);
  986.  
  987. /*
  988.  *    kQ3XMethodTypeRendererFlushFrame
  989.  *    TQ3XRendererFlushFrameMethod
  990.  *    
  991.  *    This call is only implemented by asynchronous renderers.
  992.  *    
  993.  *    The FlushFrame method is called between the StartPass and EndPass
  994.  *    methods and is called when the user wishes to flush any asynchronous
  995.  *    drawing tasks (which draw to the drawcontext), but does not want 
  996.  *    to block.
  997.  *    
  998.  *    The result of this call is that an image should "eventually" appear
  999.  *    asynchronously.
  1000.  *    
  1001.  *    For asynchronous rendering, this call is non-blocking.
  1002.  *    
  1003.  *    An interactive renderer should ensure that all received
  1004.  *    geometries are drawn in the image.
  1005.  *    
  1006.  *    An interactive renderer that talks to hardware should force
  1007.  *    the hardware to generate an image.
  1008.  *    
  1009.  *    A deferred renderer should exhibit a similar behaviour,
  1010.  *    though it is not required.  A deferred renderer should spawn
  1011.  *    a process that generates a partial image from the currently
  1012.  *    accumulated drawing state. 
  1013.  *    
  1014.  *    However, for renderers such as ray-tracers which generally are
  1015.  *    quite compute-intensive, FlushFrame is not required and is a no-op.
  1016.  *
  1017.  *    OPTIONAL
  1018.  */
  1019. #define kQ3XMethodTypeRendererFlushFrame    \
  1020.     Q3_METHOD_TYPE('r','d','f','l')
  1021. typedef TQ3Status (*TQ3XRendererFlushFrameMethod)(
  1022.     TQ3ViewObject            view,
  1023.     void                    *rendererPrivate,
  1024.     TQ3DrawContextObject    drawContext);
  1025.  
  1026. /*
  1027.  *    kQ3XMethodTypeRendererEndPass
  1028.  *    TQ3XRendererEndPassMethod
  1029.  *    
  1030.  *    The EndPass method is called at Q3View_EndRendering and signals
  1031.  *    the end of submit commands to the view.
  1032.  *
  1033.  *    If an error occurs, the renderer should call Q3XError_Post and
  1034.  *    return kQ3ViewStatusError.
  1035.  *    
  1036.  *    If a renderer requires another pass on the renderering data,
  1037.  *    it should return kQ3ViewStatusRetraverse.
  1038.  *    
  1039.  *    If rendering was cancelled, this function will not be called
  1040.  *    and the view will handle returning kQ3ViewStatusCancelled;
  1041.  *    
  1042.  *    Otherwise, your renderer should begin completing the process of 
  1043.  *    generating the image in the drawcontext. If you have buffered
  1044.  *    any drawing data, flush it. RendererEnd should have a similar
  1045.  *    effect as RendererFlushFrame.
  1046.  *    
  1047.  *    If the renderer is synchronous:
  1048.  *        - complete rendering of the entire frame
  1049.  *        if the renderer supports kQ3RendererClassSupportDoubleBuffer
  1050.  *            - Update the front buffer
  1051.  *        else
  1052.  *            - DrawContext will update the front buffer after returning
  1053.  *
  1054.  *    If the renderer is asynchronous
  1055.  *        - spawn rendering thread for entire frame
  1056.  *        if the renderer supports kQ3RendererClassSupportDoubleBuffer,
  1057.  *            - you must eventually update the front buffer asynchronously
  1058.  *        else
  1059.  *            - you must eventually update the back buffer asynchronously
  1060.  *            
  1061.  *    REQUIRED
  1062.  */
  1063. #define kQ3XMethodTypeRendererEndPass    \
  1064.     Q3_METHOD_TYPE('r','d','e','d')
  1065. typedef TQ3ViewStatus (*TQ3XRendererEndPassMethod)(
  1066.     TQ3ViewObject            view,
  1067.     void                    *rendererPrivate);
  1068.  
  1069. /*
  1070.  *    kQ3XMethodTypeRendererEndFrame
  1071.  *    TQ3XRendererEndFrame
  1072.  *    
  1073.  *    This call is only implemented by asynchronous renderers.
  1074.  *
  1075.  *    The EndFrame method is called from Q3View_Sync, which is
  1076.  *    called after Q3View_EndRendering and signals that the user
  1077.  *    wishes to see the completed image and is willing to block.
  1078.  *    
  1079.  *    If your renderer supports kQ3RendererFlagDoubleBuffer
  1080.  *        - update the front buffer completely 
  1081.  *    else
  1082.  *        - update the back buffer completely
  1083.  *
  1084.  *    This call is equivalent in functionality to RendererFlushFrame
  1085.  *    but blocks until the image is completed.
  1086.  *    
  1087.  *    If no method is supplied, the default is a no-op.
  1088.  *    
  1089.  *    NOTE: Registering a method of this type indicates that your renderer will
  1090.  *    be rendering after Q3View_EndRendering has been called.
  1091.  *    
  1092.  *    OPTIONAL
  1093.  */
  1094. #define kQ3XMethodTypeRendererEndFrame    \
  1095.     Q3_METHOD_TYPE('r','d','s','y')
  1096. typedef TQ3Status (*TQ3XRendererEndFrameMethod)(
  1097.     TQ3ViewObject            view,
  1098.     void                    *rendererPrivate,
  1099.     TQ3DrawContextObject    drawContext);
  1100.     
  1101. /*
  1102.  *    The RendererCancel method is called after Q3View_StartRendering
  1103.  *    and signals the termination of all rendering operations.
  1104.  *
  1105.  *    A renderer should clean up any cached data, and cancel all 
  1106.  *    rendering operations.
  1107.  *    
  1108.  *    If called before Q3View_EndRendering, the RendererEnd method
  1109.  *    is NOT called.
  1110.  *    
  1111.  *    If called after Q3View_EndRendering, the renderer should kill
  1112.  *    any threads and terminate any further rendering.
  1113.  *    
  1114.  *    REQUIRED
  1115.  */
  1116. #define kQ3XMethodTypeRendererCancel    \
  1117.     Q3_METHOD_TYPE('r','d','a','b')
  1118. typedef void (*TQ3XRendererCancelMethod)(
  1119.     TQ3ViewObject            view,
  1120.     void                    *rendererPrivate);
  1121.  
  1122.  
  1123. /******************************************************************************
  1124.  **                                                                             **
  1125.  **                        Renderer DrawContext Methods                         **
  1126.  **                                                                             **
  1127.  *****************************************************************************/
  1128.  
  1129. /*
  1130.  *    kQ3XMethodTypeRendererPush
  1131.  *    TQ3XRendererPushMethod
  1132.  *    
  1133.  *    kQ3XMethodTypeRendererPop
  1134.  *    TQ3XRendererPopMethod
  1135.  *    
  1136.  *    These methods are called whenever the graphics state in the view
  1137.  *    is pushed or popped. The user may isolate state by calling:
  1138.  *    
  1139.  *    Q3Attribute_Submit(kQ3AttributeTypeDiffuseColor, &red, view);
  1140.  *    Q3Attribute_Submit(kQ3AttributeTypeTransparencyColor, &blue, view);
  1141.  *    Q3Attribute_Submit(kQ3AttributeTypeSpecularColor, &white, view);
  1142.  *    Q3Box_Submit(&unitBox, view);
  1143.  *    Q3TranslateTransform_Submit(&unitVector, view);
  1144.  *    Q3Push_Submit(view);
  1145.  *        Q3Attribute_Submit(kQ3AttributeTypeDiffuseColor, &blue, view);
  1146.  *        Q3Attribute_Submit(kQ3AttributeTypeTransparencyColor, &green, view);
  1147.  *        Q3Box_Submit(&unitBox, view);
  1148.  *    Q3Pop_Submit(view);    
  1149.  *    Q3TranslateTransform_Submit(&unitVector, view);
  1150.  *    Q3Box_Submit(&unitBox, view);
  1151.  *    
  1152.  *    or by submitting a display group which pushes and pops.
  1153.  *    
  1154.  *    If you support RendererPush and RendererPop in your renderer:
  1155.  *        - you must maintain your drawing state as a stack, as well.
  1156.  *        - you will not be updated with the popped state after
  1157.  *            RendererPop is called.
  1158.  *
  1159.  *    If you do not support Push and Pop in your renderer:
  1160.  *        - you may maintain a single copy of the drawing state.
  1161.  *        - you will be updated with changed fields after the view stack is
  1162.  *            popped.
  1163.  *
  1164.  *    A renderer that supports Push and Pop gets called in the following
  1165.  *    sequence (from example above):
  1166.  *    
  1167.  *    RendererUpdateAttributeDiffuseColor(&red,...)
  1168.  *    RendererUpdateAttributeTransparencyColor(&blue,...)
  1169.  *    RendererUpdateAttributeSpecularColor(&white,...)
  1170.  *    RendererUpdateMatrixLocalToWorld(...)
  1171.  *    RendererSubmitGeometryBox(...)
  1172.  *    RendererPush(...)
  1173.  *        RendererUpdateAttributeDiffuseColor(&blue,...)
  1174.  *        RendererUpdateAttributeTransparencyColor(&green,...)
  1175.  *        RendererSubmitGeometryBox(...)
  1176.  *    RendererPop(...)
  1177.  *    RendererUpdateMatrixLocalToWorld(...)
  1178.  *    RendererSubmitGeometryBox(...)
  1179.  *
  1180.  *    A renderer that does not supports Push and Pop gets called in the
  1181.  *    following sequence:
  1182.  *    
  1183.  *    RendererUpdateAttributeDiffuseColor(&red,...)
  1184.  *    RendererUpdateAttributeTransparencyColor(&blue,...)
  1185.  *    RendererUpdateAttributeSpecularColor(&white,...)
  1186.  *    RendererUpdateMatrixLocalToWorld(...)
  1187.  *    RendererSubmitGeometryBox(...)
  1188.  *        RendererUpdateAttributeDiffuseColor(&blue,...)
  1189.  *        RendererUpdateAttributeTransparencyColor(&green,...)
  1190.  *        RendererSubmitGeometryBox(...)
  1191.  *    RendererUpdateAttributeDiffuseColor(&red,...)
  1192.  *    RendererUpdateAttributeTransparencyColor(&blue,...)
  1193.  *    RendererUpdateMatrixLocalToWorld(...)
  1194.  *    RendererSubmitGeometryBox(...)
  1195.  *    
  1196.  */
  1197. #define kQ3XMethodTypeRendererPush    \
  1198.     Q3_METHOD_TYPE('r','d','p','s')
  1199. typedef TQ3Status (*TQ3XRendererPushMethod)(
  1200.     TQ3ViewObject            view,
  1201.     void                    *rendererPrivate);
  1202.  
  1203. #define kQ3XMethodTypeRendererPop    \
  1204.     Q3_METHOD_TYPE('r','d','p','o')
  1205. typedef TQ3Status (*TQ3XRendererPopMethod)(
  1206.     TQ3ViewObject            view,
  1207.     void                    *rendererPrivate);
  1208.  
  1209. /******************************************************************************
  1210.  **                                                                             **
  1211.  **                            Renderer Cull Methods                             **
  1212.  **                                                                             **
  1213.  *****************************************************************************/
  1214. /*
  1215.  *    kQ3XMethodTypeRendererIsBoundingBoxVisible
  1216.  *    TQ3XRendererIsBoundingBoxVisibleMethod
  1217.  *    
  1218.  *    This method is called to cull complex groups and geometries 
  1219.  *    given their bounding box in local space.
  1220.  *    
  1221.  *    It should transform the local-space bounding box coordinates to
  1222.  *    frustum space and return a TQ3Boolean return value indicating
  1223.  *    whether the box appears within the viewing frustum.
  1224.  *    
  1225.  *    If no method is supplied, the default behvaiour is to return
  1226.  *    kQ3True.
  1227.  *    
  1228.  *    TODO: Default to cull to { (-1,1), (-1,1), (0,1) } frustum?
  1229.  */
  1230. #define kQ3XMethodTypeRendererIsBoundingBoxVisible    \
  1231.     Q3_METHOD_TYPE('r','d','b','x')
  1232. typedef TQ3Boolean (*TQ3XRendererIsBoundingBoxVisibleMethod)(
  1233.     TQ3ViewObject            view,
  1234.     void                    *rendererPrivate,
  1235.     const TQ3BoundingBox    *bBox);
  1236.  
  1237. /******************************************************************************
  1238.  **                                                                             **
  1239.  **                        Renderer Object Support Methods                         **
  1240.  **                                                                             **
  1241.  *****************************************************************************/
  1242.  
  1243. /*
  1244.  *    Drawing methods (Geometry, Camera, Lights)
  1245.  *
  1246.  */
  1247.  
  1248. /*
  1249.  *    Geometry MetaHandler
  1250.  *    
  1251.  *    This metaHandler is required to support 
  1252.  *    
  1253.  *    kQ3GeometryTypeTriangle
  1254.  *    kQ3GeometryTypeLine
  1255.  *    kQ3GeometryTypePoint
  1256.  *    kQ3GeometryTypeMarker
  1257.  *    kQ3GeometryTypePixmapMarker
  1258.  *    
  1259.  *    REQUIRED
  1260.  */
  1261. #define kQ3XMethodTypeRendererSubmitGeometryMetaHandler    \
  1262.     Q3_METHOD_TYPE('r','d','g','m')
  1263. typedef TQ3XFunctionPointer (*TQ3XRendererSubmitGeometryMetaHandlerMethod)(
  1264.     TQ3ObjectType                    geometryType);
  1265. /*
  1266.  *    The TQ3XRendererSubmitGeometryMetaHandlerMethod switches on geometryType
  1267.  *    of kQ3GeometryTypeFoo and returns methods of type:
  1268.  */
  1269. typedef TQ3Status (*TQ3XRendererSubmitGeometryMethod)(
  1270.     TQ3ViewObject                    view,
  1271.     void                            *rendererPrivate,
  1272.     TQ3GeometryObject                geometry,
  1273.     const void                        *publicData);
  1274.  
  1275.  
  1276. /*
  1277.  *    Camera MetaHandler
  1278.  *    
  1279.  *    This metaHandler, if supplied, indicates that your renderer
  1280.  *    handles deferred transformation of the main camera within a scene.
  1281.  *    
  1282.  *    If not supplied, or an unsupported camera is used, the view will do
  1283.  *    the transformation for the renderer and pass in a camera in the 
  1284.  *    StartPass method.
  1285.  *    
  1286.  *    OPTIONAL
  1287.  */
  1288. #define kQ3XMethodTypeRendererSubmitCameraMetaHandler    \
  1289.     Q3_METHOD_TYPE('r','d','c','m')
  1290. typedef TQ3XFunctionPointer (*TQ3XRendererSubmitCameraMetaHandlerMethod)(
  1291.     TQ3ObjectType                    cameraType);
  1292. /*
  1293.  *    The TQ3XRendererSubmitCameraMetaHandlerMethod switches on cameraType
  1294.  *    of kQ3CameraTypeFoo and returns methods of type:
  1295.  */
  1296. typedef TQ3Status (*TQ3XRendererSubmitCameraMethod)(
  1297.     TQ3ViewObject                    view,
  1298.     void                            *rendererPrivate,
  1299.     TQ3CameraObject                    camera,
  1300.     const void                        *publicData);
  1301.  
  1302.  
  1303. /*
  1304.  *    Light MetaHandler
  1305.  *    
  1306.  *    This metaHandler, if supplied, indicates that your renderer
  1307.  *    handles deferred transformation of lights within a scene.
  1308.  *    
  1309.  *    If an unsupported light is encountered, it is ignored.
  1310.  *
  1311.  *    OPTIONAL
  1312.  */
  1313. #define kQ3XMethodTypeRendererSubmitLightMetaHandler    \
  1314.     Q3_METHOD_TYPE('r','d','l','g')
  1315. typedef TQ3XFunctionPointer (*TQ3XRendererSubmitLightMetaHandlerMethod)(
  1316.     TQ3ObjectType                    lightType);
  1317. /*
  1318.  *    The TQ3XRendererSubmitLightMetaHandlerMethod switches on lightType
  1319.  *    of kQ3LightTypeFoo and returns methods of type:
  1320.  */
  1321. typedef TQ3Status (*TQ3XRendererSubmitLightMethod)(
  1322.     TQ3ViewObject                    view,
  1323.     void                            *rendererPrivate,
  1324.     TQ3LightObject                    light,
  1325.     const void                        *publicData);
  1326.  
  1327. /*
  1328.  *
  1329.  *    Update methods
  1330.  *
  1331.  *    They are called whenever the state has changed. If the renderer supports
  1332.  *    the RendererPush and RendererPop methods, it must maintain its own state
  1333.  *    stack. Updates are not called for changed data when the view stack is
  1334.  *    popped.
  1335.  *
  1336.  *    See the comments for the RendererPush and RendererPop methods above
  1337.  *    for an example of how data is updated.
  1338.  *
  1339.  */
  1340.  
  1341. /*
  1342.  *    Style
  1343.  */
  1344. #define kQ3XMethodTypeRendererUpdateStyleMetaHandler        \
  1345.     Q3_METHOD_TYPE('r','d','y','u')
  1346. typedef TQ3XFunctionPointer (*TQ3XRendererUpdateStyleMetaHandlerMethod)(
  1347.     TQ3ObjectType                    styleType);
  1348. /*
  1349.  *    The TQ3XRendererUpdateStyleMetaHandlerMethod switches on styleType
  1350.  *    of kQ3StyleTypeFoo and returns methods of type:
  1351.  */
  1352. typedef TQ3Status (*TQ3XRendererUpdateStyleMethod)(
  1353.     TQ3ViewObject                    view,
  1354.     void                            *rendererPrivate,
  1355.     const void                        *publicData);
  1356.  
  1357. /*
  1358.  *    Attributes
  1359.  */
  1360. #define kQ3XMethodTypeRendererUpdateAttributeMetaHandler    \
  1361.     Q3_METHOD_TYPE('r','d','a','u')
  1362. typedef TQ3XFunctionPointer (*TQ3XRendererUpdateAttributeMetaHandlerMethod)(
  1363.     TQ3AttributeType                attributeType);
  1364. /*
  1365.  *    The TQ3XRendererUpdateStyleMetaHandlerMethod switches on attributeType
  1366.  *    of kQ3AttributeTypeFoo and returns methods of type:
  1367.  */
  1368. typedef TQ3Status (*TQ3XRendererUpdateAttributeMethod)(
  1369.     TQ3ViewObject                    view,
  1370.     void                            *rendererPrivate,
  1371.     const void                        *publicData);
  1372.  
  1373. /*
  1374.  *    Shaders
  1375.  */
  1376. #define kQ3XMethodTypeRendererUpdateShaderMetaHandler    \
  1377.     Q3_METHOD_TYPE('r','d','s','u')
  1378. typedef TQ3XFunctionPointer (*TQ3XRendererUpdateShaderMetaHandlerMethod)(
  1379.     TQ3ObjectType                    shaderType);
  1380.     
  1381. /*
  1382.  *    The TQ3XRendererUpdateShaderMetaHandlerMethod switches on shaderType
  1383.  *    of kQ3ShaderTypeFoo and returns methods of type:
  1384.  */
  1385. typedef TQ3Status (*TQ3XRendererUpdateShaderMethod)(
  1386.     TQ3ViewObject                    view,
  1387.     void                            *rendererPrivate,
  1388.     TQ3Object                        shaderObject);
  1389.  
  1390. /*
  1391.  *    Matrices
  1392.  */
  1393. #define kQ3XMethodTypeRendererUpdateMatrixMetaHandler                    \
  1394.     Q3_METHOD_TYPE('r','d','x','u')
  1395. typedef TQ3XMetaHandler TQ3XRendererUpdateMatrixMetaHandlerMethod;
  1396.  
  1397. /*
  1398.  *    The TQ3XRendererUpdateShaderMetaHandlerMethod switches on methods
  1399.  *    of the form kQ3MethodTypeRendererUpdateMatrixFoo:
  1400.  */
  1401. #define kQ3XMethodTypeRendererUpdateMatrixLocalToWorld                    \
  1402.     Q3_METHOD_TYPE('u','l','w','x')
  1403. #define kQ3XMethodTypeRendererUpdateMatrixLocalToWorldInverse            \
  1404.     Q3_METHOD_TYPE('u','l','w','i')
  1405. #define kQ3XMethodTypeRendererUpdateMatrixLocalToWorldInverseTranspose    \
  1406.     Q3_METHOD_TYPE('u','l','w','t')
  1407. #define kQ3XMethodTypeRendererUpdateMatrixLocalToCamera                    \
  1408.     Q3_METHOD_TYPE('u','l','c','x')
  1409. #define kQ3XMethodTypeRendererUpdateMatrixLocalToFrustum                \
  1410.     Q3_METHOD_TYPE('u','l','f','x')
  1411. #define kQ3XMethodTypeRendererUpdateMatrixWorldToFrustum                \
  1412.     Q3_METHOD_TYPE('u','w','f','x')
  1413.  
  1414. /*
  1415.  *    and returns methods of type:
  1416.  */
  1417. typedef TQ3Status (*TQ3XRendererUpdateMatrixMethod)(
  1418.     TQ3ViewObject                    view,
  1419.     void                            *rendererPrivate,
  1420.     const TQ3Matrix4x4                *matrix);
  1421.  
  1422. #ifdef __cplusplus
  1423. }
  1424. #endif    /* __cplusplus */
  1425.  
  1426. #if defined(__MWERKS__)
  1427.     #pragma enumsalwaysint reset
  1428. #elif defined(__xlc) || defined(__xlC) || defined(__xlC__) || defined(__XLC121__)
  1429.     #pragma options enum=reset
  1430. #endif
  1431.  
  1432. #endif  /*  QD3DRenderer_h  */
  1433.